<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .container {
      height: 200px;
      width: 400px;
      background: #161;
      /* position: relative; */
    }

    .content {
      position: relative;
      /* width: 100px; */
      /* height: 100px; */
      background: beige;
      float: left;
      left: 50%;
      transform: translateX(-50%);
    }
  </style>
</head>

<body>
  <div class="container">
    <div class="content">
      我是浮动元素
    </div>
  </div>
</body>

</html>